"use strict";
const common_vendor = require("../../common/vendor.js");
const uniFilePicker = () => "../../uni_modules/uni-file-picker/components/uni-file-picker/uni-file-picker.js";
const _sfc_main = {
  components: {
    uniFilePicker
  },
  data() {
    return {
      sendData: {
        feedbackContent: "",
        //反馈内容
        mobile: "",
        //联系方式
        htmlText: "<div><img src='https://heart-field-1312908194.cos.ap-shanghai.myqcloud.com/img/login/background.png'/></div>"
      },
      problemImgs: [],
      btnLoading: false,
      user: {}
    };
  },
  onLoad(e) {
    this.user = JSON.parse(e.user);
  },
  methods: {
    commitFeedback() {
      if (this.sendData.mobile && !/^1[3-9]\d{9}$/.test(this.sendData.mobile)) {
        common_vendor.index.showToast({ icon: "none", title: "请填写正确的手机号格式！" });
      } else {
        common_vendor.index.showLoading();
        console.log(this.problemImgs);
        common_vendor.index.request({
          url: "https://api.emailjs.com/api/v1.0/email/send",
          data: {
            service_id: "service_kv47xq2",
            template_id: "Heart Field Feedback",
            user_id: "c4K9D6MG6soFueVsc",
            template_params: {
              name: this.user.info.userName,
              id: this.user.id,
              body: this.sendData.feedbackContent,
              img: this.problemImgs[0].fileID,
              phone: this.sendData.mobile
            }
          },
          method: "POST",
          header: { "Content-Type": "application/json" },
          success(res) {
            console.log(res);
            common_vendor.index.hideLoading();
            common_vendor.index.navigateBack();
            common_vendor.index.showToast({ icon: "none", title: "反馈提交成功！感谢您的支持！" });
          },
          fail(err) {
            console.log(err);
            common_vendor.index.hideLoading();
            common_vendor.index.showToast({ icon: "none", title: "反馈提交失败！请直接邮件联系工作人员处理（heart-field@outlook.com）！" });
          }
        });
      }
    }
  }
};
if (!Array) {
  const _easycom_uni_file_picker2 = common_vendor.resolveComponent("uni-file-picker");
  _easycom_uni_file_picker2();
}
const _easycom_uni_file_picker = () => "../../uni_modules/uni-file-picker/components/uni-file-picker/uni-file-picker.js";
if (!Math) {
  _easycom_uni_file_picker();
}
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  return {
    a: common_vendor.t($data.sendData.feedbackContent.length),
    b: $data.sendData.feedbackContent,
    c: common_vendor.o(($event) => $data.sendData.feedbackContent = $event.detail.value),
    d: common_vendor.t($data.problemImgs.length),
    e: common_vendor.o(($event) => $data.problemImgs = $event),
    f: common_vendor.p({
      limit: "1",
      ["source-type"]: ["album", "camera"],
      modelValue: $data.problemImgs
    }),
    g: $data.sendData.mobile,
    h: common_vendor.o(($event) => $data.sendData.mobile = $event.detail.value),
    i: !$data.sendData.feedbackContent,
    j: common_vendor.o((...args) => $options.commitFeedback && $options.commitFeedback(...args))
  };
}
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "D:/Project/heart-3.0/heart-field-3.0/pages/feedback/feedback.vue"]]);
wx.createPage(MiniProgramPage);
